<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>mixin</title>
</head>
<body>
<div id="app">{{hello()}}-日期{{getData()}}</div>
<div id="vue">日期{{getData()}}</div>
<script src="../vue.js"></script>
<script>
    var myMixin = {
        created: function () {
            this.hello()
        },
        methods:{
            hello(){
                // console.log('hello');
                return 'hello';
            },
            getData(){
                let dataNow =new Date(),
                    year = dataNow.getFullYear(),
                    months =dataNow.getMonth()+1,
                    bay = dataNow.getDate();
                months = String(months).padStart(2,'0');
                // console.log(`${year}${months}${bay}`)
                return `${year}-${months}-${bay}`;
            }
        }
    }

     var vm = new Vue({
        el:"#app",
        mixins:[myMixin]
    })
    var vm = new Vue({
        el:"#vue",
        mixins:[myMixin]
    })
</script>
</body>
</html>